package br.com.toscano.gobra.view;

import javax.inject.Inject;

import br.com.toscano.gobra.business.SituacaoObraBC;
import br.com.toscano.gobra.domain.SituacaoObra;
import br.gov.frameworkdemoiselle.annotation.PreviousView;
import br.gov.frameworkdemoiselle.stereotype.ViewController;
import br.gov.frameworkdemoiselle.template.AbstractEditPageBean;
import br.gov.frameworkdemoiselle.transaction.Transactional;

@ViewController
@PreviousView("./situacaoObra_list.jsf")
public class SituacaoObraEditMB extends AbstractEditPageBean<SituacaoObra, Long> {

	private static final long serialVersionUID = 1L;

	@Inject
	private SituacaoObraBC situacaoObraBC;
	
	@Override
	@Transactional
	public String delete() {
		this.situacaoObraBC.delete(getId());
		return getPreviousView();
	}
	
	@Override
	@Transactional
	public String insert() {
		this.situacaoObraBC.insert(getBean());
		return getPreviousView();
	}
	
	@Override
	@Transactional
	public String update() {
		this.situacaoObraBC.update(getBean());
		return getPreviousView();
	}
	

	@Override
	protected SituacaoObra handleLoad(Long id) {
		setBean(this.situacaoObraBC.load(id));
		return getBean();
	}

}